<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" placeholder="宠物名称" v-model="pet.type">{{info}}<br>
    <input type="text" placeholder="数量" v-model="pet.num"><br>
    <input type="text" placeholder="宠物种类" v-model="pet.breed"><br>
    <input type="button" value="添加" @click="add()">
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
 <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
     <script>
         let v = new Vue({
             el:"body>div",
             data:{
                 pet:{
                     type:"",
                     num:"",
                     breed:""
                 },
                 info:""

             },
             methods:{
                 add(){
                     axios.post("/petadd",v.pet).then(function (response) {
                         if(response.data==1){
                             alert("添加成功")
                         }
                     })
                 },
                 f(){
                     axios.get("/check?type="+v.pet.type).then(function (response) {
                         if(response.data==2){
                             v.info="已存在"
                         }else {
                             v.info="可以"
                         }
                     })
                 }

             }

         })
     </script>
</body>
</html>